import React from 'react';
import { Row, Col, Button } from 'antd';
import { connect } from 'dva';
import { timeFormat } from '@/utils/common';
import styles from './index.less';
import Download from '@/components/Download';
import Title from '../Title';
import { Link } from 'react-router-dom';
const Source = ({ notification, lawList, dispatch, excelList }) => {
  const goDetail = url => {
    dispatch({
      type: '$router/forward',
      payload: {
        url,
      },
    });
  };
  return (
    <div>
      <div className={styles.container}>
        <div className={styles.notice}>
          <Title title="公告通知">
            {excelList && excelList.length >= 1 && (
              <Button
                type="link"
                onClick={() => goDetail('messageManage/notice')}
              >
                更多 >>
              </Button>
            )}
          </Title>
          <div style={{ padding: '0 22px 22px 30px' }}>
            {notification &&
              notification.map(item => (
                <div className={styles.item}>
                  <Button
                    type="link"
                    onClick={() =>
                      goDetail(`messageManage/detail?id=${item.uuid}&type=0`)
                    }
                  >
                    {item.title}
                  </Button>
                  <label>{timeFormat(item.createTime, 'YYYY-MM-DD')}</label>
                </div>
              ))}
          </div>
        </div>
        <div className={styles.notice}>
          <Title title="法律法规">
            {excelList && excelList.length >= 1 && (
              <Button
                type="link"
                onClick={() => goDetail('messageManage/legislation')}
              >
                更多 >>
              </Button>
            )}
          </Title>
          <div style={{ padding: '0 22px 22px 30px' }}>
            {lawList &&
              lawList.map(item => (
                <div className={styles.item}>
                  <Button
                    type="link"
                    onClick={() =>
                      goDetail(`messageManage/detail?id=${item.uuid}&type=1`)
                    }
                  >
                    {item.title}
                  </Button>
                  <label>{timeFormat(item.createTime, 'YYYY-MM-DD')}</label>
                </div>
              ))}
          </div>
        </div>
        <div className={styles.notice}>
          <Title title="常用表格下载">
            {excelList && excelList.length >= 1 && (
              <Button
                type="link"
                onClick={() => goDetail('messageManage/excel')}
              >
                更多 >>
              </Button>
            )}
          </Title>
          <div style={{ padding: '0 22px 22px 30px' }}>
            {excelList &&
              excelList.map(item => (
                <div className={styles.item}>
                  <Button type="link">{item.name}</Button>
                  <Download {...item}>下载</Download>
                </div>
              ))}
          </div>
        </div>
      </div>
    </div>
  );
};
export default connect(state => state.home)(Source);
